#@embedLayout()

#define content()
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:true">
        <div id="datagridIdExt"></div>

        <div id="datagridTbExt">
            <div class="row">
                <div class="row">
                    <div class="col-md-12" style="padding: 5px 25px;">
                        <a href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'icon-pill_add',plain:true" id='dict_add'>增加#(displayName)</a>
                        <a href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'icon-pill_go',plain:true" id='dict_edit'>编辑#(displayName)</a>
                        <a href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'icon-pill_delete',plain:true" id='dict_remove'>移除#(displayName)</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

#end


#define css()

#end


#define js()


<script type="text/javascript">

    var _datagridExt = "datagridIdExt", _formExt = "formIdExt", _datagridTbExt = "datagridTbExt";
    var datagridListUrlExt = contextRootPath + '/dict/dictList?dict.dt_id=#(dtId)';
    // 解决乱码
    var  displayName= encodeURI(encodeURI("#(displayName)"));

    $(function () {

        //初始化表格
        $("#" + _datagridExt).datagrid({
            url: datagridListUrlExt,
            fit: true,
            border: false,
            rownumbers: true,
            pageSize: 30,
            toolbar: '#' + _datagridTbExt,
            singleSelect: false,
            pagination: true,
            nowrap: false,
            striped: true,
            fitColumns: true,
            columns: [[
                {field: DBConts.TABLE_DICT.DICT_ID, title: DBConts.TABLE_DICT.DICT_ID, width: 100, checkbox: true},
                {
                    field: DBConts.TABLE_DICT.DICT_NAME,
                    title: "#(displayName)名称",
                    sortable: true
                }, {
                    field: DBConts.TABLE_DICT.DICT_TEXT,
                    title: "#(displayName)内容",
                    sortable: true
                }
            ]]
        });


        $("#dict_add").on('click', function () {
            var params = {};
            params.title = "增加#(displayName)";
            params.width = 2000;
            params.height = 2000;
            params.top = '10px';
            params.modal = true;
            params.dlgId = "dict_ext_form_dlg_id",
                params.iconCls = 'icon-application_add';
            params.url = contextRootPath + '/dict/add?isDisplay=#(isDisplay)&displayName='+displayName+'&dtId=#(dtId)';
            params.buttons = [{
                text: '提交',
                iconCls: 'icon-application_go',
                handler: function () {
                    dict_datagrid_save('add');
                }
            }, {
                text: '重置',
                iconCls: 'icon-application_side_contract',
                handler: function () {
                    clearForm('formIdExt')
                }
            }];

            crud_dlg(params);
        });


        $("#dict_edit").on('click', function () {
            var selected = $('#' + _datagridExt).datagrid('getSelected');


            if (selected == null) {
                $.messager.alert("提示框", "请选择需要操作的#(displayName)!", "warning");
                return;
            }

            var selections = $('#' + _datagridExt).datagrid('getSelections');

            if (selections.length < 1) {
                $.messager.alert("提示框", "请选择需要操作的#(displayName)!", "warning");
                return;
            } else if (selections.length > 1) {
                $.messager.alert("提示框", "编辑的#(displayName)为多个，请重新选择!", "warning");
                return;
            }

            var params = {};
            params.dlgId = "dict_ext_form_dlg_id",
                params.title = "编辑#(displayName)";
            params.width = 2000;
            params.height = 2000;
            params.top = '10px';
            params.modal = true;
            params.iconCls = 'icon-application_edit';
            params.url = contextRootPath + '/dict/edit/?isDisplay=#(isDisplay)&displayName='+displayName+'&dictId=' + selected[DBConts.TABLE_DICT.DICT_ID];
            params.buttons = [{
                text: '提交',
                iconCls: 'icon-application_go',
                handler: function () {
                    dict_datagrid_save();
                }
            }, {
                text: '关闭',
                iconCls: 'icon-application_side_contract',
                handler: function () {
                    $('#dict_ext_form_dlg_id').dialog('close');
                }
            }];

            crud_dlg(params);
        });


        $("#dict_remove").on('click', function () {
            var selections = $('#' + _datagridExt).datagrid('getSelections');
            var ids = "";

            if (selections.length < 1) {
                $.messager.alert("提示框", "请选择需要操作的#(displayName)!", "warning");
                return;
            }

            $.messager.confirm('确认框', '请确定需要删除所选择的#(displayName)么？', function (r) {
                if (r) {
                    $.each(selections, function (i, v) {
                        ids += v[DBConts.TABLE_DICT.DICT_ID] + ",";
                    });

                    $.post(contextRootPath + "/dict/remove?isDisplay=#(isDisplay)&displayName="+displayName+"&ids=" + ids, function (data) {
                        var params = {};
                        params.element = _datagridExt;
                        params.data = data;
                        params.isClose = false;
                        resultCallback(params);
                    }, 'json');
                }
            });


        });

    });
</script>

#end



